package com.liangtian.mdm.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ConstantBean {


    public static final String CURRENT_SESSION_USER = "sessionUser";

    public static final String CURRENT_SESSION_USER_PERMISSIONS = "sessionUserPermissions";

    public static final String SESSION_SECURITY_CODE = "sessionSecCode";

    public static final String EXCLUDEDPATTERN = "_UPDATE,_DIS,SYS_,V_,AM_,WF_,ACT_,PRO_";

    //系统中非物料模块使用到了唯一性校验这块的属性，现在需要将参与唯一性校验的字符串“&”与“@”符号特殊处理下
    //2018-01-23 17:27刘晶添加此处
    public static String REPLACE_AD_FH = "*_*";//替换“&”符号
    public static String REPLACE_AT_FH = "@_@";//替换“@”符号

    //分发服务数据格式
    public static final String DIS_TYPE = "XML";

    //由于系统里有拦截器 CameHumpInterceptor   对所有查询返回结果中的系统字段命名做了转义将带有下划线的统一修改成了驼峰命名规范  for example user_name --->userName
    public static String underlineToCamelhump(String str) {
        str = str.toLowerCase();
        Matcher matcher = Pattern.compile("_[a-z]").matcher(str);
        StringBuilder builder = new StringBuilder(str);
        for (int i = 0; matcher.find(); i++) {
            builder.replace(matcher.start() - i, matcher.end() - i, matcher.group().substring(1).toUpperCase());
        }
        if (Character.isUpperCase(builder.charAt(0))) {
            builder.replace(0, 1, String.valueOf(Character.toLowerCase(builder.charAt(0))));
        }
        return builder.toString();
    }

}
